#!/bin/sh

. "$TEST_SHELL_PATH/dbops/abstract-dbops"

shell_unit_test() {
  EXCLUSIVE_OP=true
  LOCK_SLEEP=0
  echo test > "$TEST_TARGET_PATH/lock_pod"
  ! (shell_unit_test_dbops)
  check_dbops_result
}

run_op() {
  sleep 300
}

mock kubectl kubectl_mock_overwrite

kubectl_mock_overwrite() {
  mokked
  case "$*" in
    ("get $CLUSTER_CRD_NAME "*)
    echo '
      LOCK_POD='"$(cat "$TEST_TARGET_PATH/lock_pod")"'
      LOCK_TIMEOUT="$(date +%s)"
      RESOURCE_VERSION=test
      '
    echo wrong-test > "$TEST_TARGET_PATH/lock_pod"
    ;;
    *)
    not_mokked
    ;;
  esac
}
